# 对事件解释器的修改
class Interpreter
  # 战斗
  def battle(enemy_id)
    # 获取敌人信息和伤害
    enemy_info = Game_EnemyInfo.new(enemy_id)
    d = enemy_info.getDamage
    # 判断能否战胜
    if d == -1
      # 播放警告SE
      $game_system.se_play($data_system.buzzer_se)
      # 等待
      @wait_count = 24
      # 中断事件
      command_end
    else
      # 绘制怪物挨打动画
      w_id = $game_party.actors[0].weapon_id
      a_id = w_id > 0 ? $data_weapons[w_id].animation2_id : 0
      if a_id > 0
        get_character(0).animation_id = a_id
        @wait_count = [@wait_count, $data_animations[a_id].frame_max].max
      end
      # 绘制角色挨打动画
      a_id = $data_enemies[enemy_id].animation2_id
      if a_id > 0
        get_character(-1).animation_id = a_id
        @wait_count = [@wait_count, $data_animations[a_id].frame_max].max
      end
      @wait_count *= 2
      # 计算伤害
      $game_party.actors[0].hp -= [$game_party.actors[0].hp, d].min
      # 死亡判断
      if $game_party.all_dead?
        $game_system.se_play($data_system.actor_collapse_se)
        $game_temp.gameover = true
        return false
      end
      # 打开独立开关A
      if @event_id > 0
        key = [$game_map.map_id, @event_id, 'A']
        $game_self_switches[key] = true
      end
      $game_map.need_refresh = true
    end
    return true
  end
end
